<template>
	<view class="page">
		<view class="content">
			<view class="title" v-if="type!='edit'">
				{{aiuseHistoryVo.content}}
			</view>
			<view class="title" v-else>
				{{content}}
			</view>
			<view v-if="type!='edit'">
				{{aiuseHistoryVo.returnContent}}
			</view>
			<view  v-else>
				{{returnContent}}
			</view>
		</view>
		<view class="foot">
			<view class="btn" @click="copy" style="background: #ffaa00;">
				一键复制
			</view>
			<view class="btn" @click="showShare()" style="background: #2168EA;">
				分享导出
			</view>
		</view>
	</view>
<!--app分享-->
		<AppShare :isAppShare="isAppShare" :appParams="appParams" @close="closeAppShare"></AppShare>
</template>

<script>
	import AppShare from '@/components/app-share.vue';
	export default {
		components: {
			AppShare
		},
		data() {
			return {
				/*app分享*/
				isAppShare: false,
				inputText: '',
				maxChars: 500,
				historyId:'',
				aiuseHistoryVo:{
					content:'',
					returnContent:'',
				},
				type:'',
				content:'',
				returnContent:''
			}
		},
		
		onLoad(options) {
			if(options.type){
				this.type = options.type
				this.content = options.title
				this.returnContent = options.val
				console.log(options)
			}
			let appId = this.getAppId();
			this.historyId = options.historyId;
			this.aiuseHistoryVo = uni.getStorageSync(appId + '_aiuseHistory_' + this.historyId)
		},
		
		methods: {
			// 复制
			copy() {
				uni.setClipboardData({
					data: this.type?this.returnContent:this.aiuseHistoryVo.returnContent, //要被复制的内容
					success: () => { //复制成功的回调函数
						uni.showToast({ //提示
							title: "复制成功",
							icon: 'none'
						})
					}
				});
			},
			//分享按钮
			showShare() {
				let self = this;
				//#ifdef MP-WEIXIN
					return;
				//#endif
				//#ifndef APP-PLUS
				self.isbottmpanel = true;
				//#endif
				//#ifdef APP-PLUS
				self.appParams.title = self.pageInfo.params.shareTitle;
				self.appParams.summary = self.pageInfo.params.name;
				// 构建页面参数
				let params = self.getShareUrlParams({
					pageId: self.pageId
				});
				self.appParams.path = '/pages/diy-page/diy-page?' + params;
				self.appParams.image = self.pageInfo.params.shareImg;
				self.isAppShare = true;
				//#endif
			},
			//关闭分享
			closeBottmpanel(data) {
				this.isbottmpanel = false;
			},
			//关闭分享
			closeAppShare(data) {
				this.isAppShare = false;
			},
		}
	}
</script>
<style>
	page {
		background: #F6F6F6;
	}
</style>
<style lang='css' scoped>
	.page {
		padding: 50rpx 20rpx;
		padding-bottom: 100rpx;
	}
	.content{
		border-radius: 20rpx;
		background: #FFFFFF;
		padding: 50rpx 30rpx;
		margin-bottom: 120rpx;
		min-height: 70vh;
		.title{
			font-weight: 500;
			font-size: 36rpx;
			color: #333333;
			margin-bottom: 47rpx;
		}
		.tex{
			font-weight: 400;
			font-size: 24rpx;
			color: #333333;
			line-height: 43rpx;
		}
	}
	.foot{
		position: fixed;
		bottom: 0;
		padding: 72rpx 0;
		width: 100%;
		display: flex;
		align-items: center;
		justify-content: center;
		background: #F6F6F6;
		.btn{
			text-align: center;
			width: 220rpx;
			height: 60rpx;
			line-height: 60rpx;
			background: #D3D3D3;
			border-radius: 30rpx;
			margin: 0 53rpx;
			font-weight: 400;
			font-size: 32rpx;
			color: #FFFFFF;
		}
	}
</style>